<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>箭头函数中this</title>
</head>
<body>
    
</body>
<script>
/* 
    箭头函数中this
        1. 箭头函数中没有自己的this，继承于外层代码块的this
        2. 不能用作构造函数
*/

var a = 111
var obj = {
    a: 222,
    fn: () => {
        console.log(this.a)
    }
}
obj.fn() // 111


var o = {
    a: 10,
    getCount: function() {
        var b = this.a // 10
        var fn = () => 20 - this.a
        return fn()
    } 
}
console.log(o.getCount()) // 10

</script>
</html>